﻿<?php
class IndexAction extends Action {
  function _initialize() {
    if (ACTION_NAME != "login") {
      $this->checkLogin();
    }
  }

  public function checkLogin() {
    header('content-Type=text/html;charset=utf-8');
    if ($_SESSION['user_name'] != "ehs" && $_SESSION['password'] != "ehscn") {
	  // iconv("GBK", "UTF-8", $content);__URL__.'/login'
	  //exit(__URL__.'/login');
	  $this->assign('jumpUrl',__URL__.'/login');
      $this->error('您还没有登陆，请重新登陆，页面跳转中~');
    }
  }

  public function index() {
    $this->display();
  }

  /*  登陆  */
  public function login() {
    if ($_POST['user_name'] == "ehs" && $_POST['password'] == "ehscn") {
	  //unset($_SESSION["__hash__"]);
      $_SESSION['admin_name'] = "ehs";
      $_SESSION['password'] = "ehscn";
	  $_SESSION['isAdmin']="1";
	  $_SESSION['admin_id']=3;
	 // exit();
      $this->assign('jumpUrl',__URL__.'/index');
      $this->success('登录成功，页面跳转中~');
    }else {
      $this->display('lawAdmin:login');
    }
  }
}
?>